const http = require('http')
const server = http.createServer()
server.on('request', (req, res) => { //req在这个函数中是第一个参数,res是相应对象，将数据返回给浏览器，方法是res.end(内容)
    //req可以获得用户端访问的地址，和请求的方法，get和post
    const url = req.url;
    const method = req.method;
    const str = 'You request url is' + url + ',and request method is ' + method;
    console.log(str);
    res.end(str)
})
server.listen(80, () => {
    console.log('server running at http://127.0.0.1');
})